cmake_minimum_required(VERSION 3.10)
project(scan CXX)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED True)

# 添加可执行文件
add_executable(scan main.cpp)

# 设置包含目录
target_include_directories(scan PUBLIC
    ${CMAKE_CURRENT_SOURCE_DIR}/help
    ${CMAKE_CURRENT_SOURCE_DIR}/icmpScan
    ${CMAKE_CURRENT_SOURCE_DIR}/portScan/dataPacket/buildPacket
    ${CMAKE_CURRENT_SOURCE_DIR}/portScan/dataPacket/checkSum
    ${CMAKE_CURRENT_SOURCE_DIR}/portScan/dataPacket/setFlags
    ${CMAKE_CURRENT_SOURCE_DIR}/portScan/portInfo
    ${CMAKE_CURRENT_SOURCE_DIR}/portScan/scanModule
    ${CMAKE_CURRENT_SOURCE_DIR}/portScan/scanModule/scanObject
)


# 添加帮助模块
add_library(helpM STATIC help/help.cpp)
target_include_directories(helpM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/help ${CMAKE_CURRENT_SOURCE_DIR}/portScan/scanModule/scanObject ${CMAKE_CURRENT_SOURCE_DIR}/portScan/portInfo)

# 添加 ICMP 扫描模块
add_library(icmpScan STATIC icmpScan/icmp.cpp)
target_include_directories(icmpScan PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/icmpScan)

# 添加端口扫描模块
add_library(buildPacket STATIC portScan/dataPacket/buildPacket/buildpacket.cpp)
target_include_directories(buildPacket PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/portScan/dataPacket/buildPacket ${CMAKE_CURRENT_SOURCE_DIR}/portScan/dataPacket/checkSum)

add_library(scanObj STATIC portScan/scanModule/scanObject/scan.cpp)
target_include_directories(scanObj PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/portScan/scanModule/scanObject 
    ${CMAKE_CURRENT_SOURCE_DIR}/portScan/dataPacket/checkSum 
    ${CMAKE_CURRENT_SOURCE_DIR}/portScan/dataPacket/setFlags 
    ${CMAKE_CURRENT_SOURCE_DIR}/icmpScan 
    ${CMAKE_CURRENT_SOURCE_DIR}/portScan/dataPacket/buildPacket
    ${CMAKE_CURRENT_SOURCE_DIR}/portScan/portInfo
    ${CMAKE_CURRENT_SOURCE_DIR}/help
)


add_library(checkSum STATIC portScan/dataPacket/checkSum/checksum.cpp)
target_include_directories(checkSum PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/portScan/dataPacket/checkSum)

add_library(setFlags STATIC portScan/dataPacket/setFlags/setFlags.cpp)
target_include_directories(setFlags PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/portScan/dataPacket/setFlags)

add_library(portInfo STATIC portScan/portInfo/portInfo.cpp portScan/portInfo/saveInfo.cpp)
target_include_directories(portInfo PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/portScan/portInfo)


# 设置编译选项
target_compile_options(scan PRIVATE -Wall -O2)

# 链接库
target_link_libraries(scanObj setFlags checkSum buildPacket)

target_link_libraries(scan
    helpM
    icmpScan
    portInfo
    scanObj
    pthread
)